type name = string
type age = int
type adress = string
type telephone = int
type contact = (name * age * adress * telephone)

let rec exist x liste = match liste with
  |[] -> false
  |e::l -> x = e || exist x l;;

let rec add_list x liste = match liste with
  |[] -> x::[]
  |e::l when x < e -> x::liste
  |e::l when x = e -> liste
  |e::l -> e::add_list x l;;

let rec remove_list x liste = match liste with
  |[] -> []
  |e::l when x < e -> liste
  |e::l when x = e -> l
  |e::l -> e::remove_list x l;;

let rec map f liste = match liste with
  |[] -> []
  |e::l -> f e::map f l;;

let rec iter f liste = match liste with
   [] -> ()
  |e::l -> begin
                     f e;
                     iter f l
               end;;

let rec for_all f liste = match liste with        
    [] -> true
   |e::l -> f e && for_all f l;;

let upper_case x = if int_of_char(x) > 64 && int_of_char (x) < 91 then  x else  char_of_int (int_of_char (x) -32);;

let lower_case x = if int_of_char(x) < 64 && int_of_char (x) > 91 then  char_of_int (int_of_char x +32) else x;;

let string_of_char c = String.make 1 c;;

let string_apply f string = 
  let rec apply i = match i with    
    |0 -> (string_of_char (f string.[0]))
    |i -> apply (i-1)^string_of_char (f string.[i]) in
  apply ((String.length string)-1);;

let string_uppercase x  = string_apply upper_case x;;

